package com.zy.gpdemo.utils;

import java.io.DataInputStream;

public class Test {
	
	public String test() {
		return "true";
	}
	
	public static int makeJavaFile() {
		int res = 0;
		try {
			Runtime runtime=Runtime.getRuntime();
			Process process=runtime.exec("cmd /c javac Test1.java");
			process.waitFor();
			byte[] out = new byte[1024];
			DataInputStream dos = new DataInputStream(process.getInputStream());
			dos.read(out);
			String string= new String(out);
			if(string.indexOf("Exception")>0) {
				res = -1;
			}
		}catch (Exception e) {
			res = -1;
			e.printStackTrace();
		}
		return res;
	}
	
	public static void main(String[] args) {
//		makeJavaFile();
		try {
			System.out.println(Class.forName("Test1").getMethod("test", new Class[] {}).invoke(null, new Object[] {}));
		}catch (Exception e) {
			e.printStackTrace();
		}
	}
}
